from lib.Core.Backpack import Backpack
from lib.Player.Property import Property


class Player(object):
    def __init__(self, username, hp=3, property=None):
        super(Player, self).__init__()
        self.username = username
        self.hp = hp
        self.backpack = Backpack()

        if not isinstance(property, Property):
            raise AttributeError('property must Property type')
        self.property = property

        self.heros = []
        self.cards = []

    def setHeros(self, heros):
        if heros is None:
            heros = []
        self.heros = heros

    def setCards(self, cards):
        if cards is None:
            cards = []
        self.cards = cards

    def add_item(self, item):
        self.backpack.add_item(item)
